/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dipl.algorithm.math.utility;

import dipl.algorithm.math.geometry.op.Point2dSetOps;
import dipl.algorithm.math.primitive.Point2d;
import java.util.Random;

/**
 * Factory class for 2d polygons
 */
public class Polygon2dFactory {

	/**
	 * Creates random convex polygon.
	 * @param rand
	 * @param numPoints
	 * @return
	 */
	public static Point2d[] GenerateRandomConvexPolygon( Random rand, int numPoints ) {
		Point2d[] points = new Point2d[numPoints];
		for( int i = 0; i < numPoints; i++ ) {
			points[i] =
				new Point2d( ApfloatUtils.ValueOf( rand.nextDouble() ), ApfloatUtils.ValueOf( rand.nextDouble() ) );
		}
		return Point2dSetOps.ComputeConvexHull( points, true );
	}

}
